#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n;
    cin>>n;
    int a[100000];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans=0;
    char b[100000];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        b[i]='t';
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[j]>a[i]&&b[j]=='t'&&b[i]!='d'){
               b[j]='f';
               b[i]='d';
               continue;
            }
            if(a[j]==a[i]&&b[j]=='t'){
               b[j]='f';
               b[i]='f';
               continue;
            }
            else break;
            break;
        }
        /*if(i==n){
            for(int k=1;k<n;k++){
                if(a[k]==true){
                    b[k]='f';
                    b[i]='d';
                }
            }
        }*/
    }
    for(int i=1;i<n;i++){
        if(b[i]=='f'){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}
/*while(ans>=0){
        for(int i=2;i<=ans+1;i++){
            if(b[i]==true&&b[i-1]==true){
              if(a[i]>a[i-1]){
                  dp[i]++;
                  b[i]=false;
              }
              else{
                b[i-1]=false;
                a[i]=a[i-1];
                dp[i]++;
              }
            }
        }
    }
dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
*/
/*if(a[j]==a[i]&&b[i]==true&&a[i]!=-1&&a[i+1]!=-1){
                b[i]=false;
                continue;
            }
            else if(b[i]==true&&a[i]>a[i+1]&&a[i]!=-1&&a[i+1]!=-1){
                b[i]=false;
                a[i+1]=-1;
                ans2--;
                continue;
            }
            else if(b[i]==true&&a[i]<a[i+1]&&a[i]!=-1&&a[i+1]!=-1){
                b[i+1]=false;
                a[i]=-1;
                    ans2--;
                continue;
            }*/